#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <net/if.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>	
#include <stdio.h>
#include "logger.h"
#include "ReportProtocol.h"
#include "DataReportManager.h"
const char *recordDir="/mnt/usr/upload";
struct ndb_ns_t config_ns = {"config", "http://skynetwork.com.cn/lte/mainControlBoard"};
#ifdef HTTP
struct ndb_ns_t protocol_ns = {"http", "http://skyworks.com.cn/lte/http"};
const char* xpath = "/config:config/http:http";
#define PROTOCOL_CONFIG_FIEL    "httpcfg.xml"
#define PROTOCOL_CONFIG_FIEL_EXTERNAL    "/mnt/config/httpcfg.xml"
#endif
#ifdef FTP
struct ndb_ns_t protocol_ns = {"ftp", "http://skyworks.com.cn/lte/ftp"};
const char* xpath = "/config:config/ftp:ftp";
#define PROTOCOL_CONFIG_FIEL    "ftpcfg.xml"
#define PROTOCOL_CONFIG_FIEL_EXTERNAL    "/mnt/config/ftpcfg.xml"
#endif

ReportInterface::ReportInterface():
reportSuccess(true),
getDataTimeOut_(this, &ReportInterface::handleGetDataTmOut)
{
    sem_init(&sem_report, 0 , 1);
    sem_wait(&sem_report);
}

void ReportInterface::getmac()
{
    int sockfd;
    struct ifreq tmp;   
    char devMac[20] = {0};
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if( sockfd < 0)
    {
        LogInfo("create socket fail\n");
        return ;
    }

    memset(&tmp,0,sizeof(struct ifreq));
    strncpy(tmp.ifr_name, "eth1",sizeof(tmp.ifr_name)-1);
    if( (ioctl(sockfd,SIOCGIFHWADDR,&tmp)) < 0 )
    {
        LogInfo("mac ioctl for %s error\n","eth1");
        close(sockfd);
        return ;
    }
    close(sockfd);

    sprintf(devMac, "%02x%02x%02x%02x%02x%02x",
            (unsigned char)tmp.ifr_hwaddr.sa_data[0],
            (unsigned char)tmp.ifr_hwaddr.sa_data[1],
            (unsigned char)tmp.ifr_hwaddr.sa_data[2],
            (unsigned char)tmp.ifr_hwaddr.sa_data[3],
            (unsigned char)tmp.ifr_hwaddr.sa_data[4],
            (unsigned char)tmp.ifr_hwaddr.sa_data[5]
            );
    int i = 0, j = 0;
    for (; i < 12; i++)
    {
        mac12[i] = toupper(devMac[i]);
        mac18[j++] =  toupper(devMac[i]);
        if ( i%2 != 0 && i != 0 && i != 11)
        {
             mac18[j++] = ':';
        }
    }
    
    LogInfo("mac is %s , mac is %s", mac18, mac12);
    

}

void ReportInterface::initReport()
{
    TimerPtr->queue(ReportIntvl, &getDataTimeOut_);
    getmac();
    DIR *pDir = NULL;
    pDir = opendir(recordDir);
    if (pDir == NULL) 
    {
        if (mkdir(recordDir, 0777) != 0)
        {
            LogError("create upload dir %s falied\n", recordDir);
            return;
        }
    }
    else
        closedir(pDir);
    system("rm /mnt/usr/upload/* -rf");
}

char *ReportInterface::returnMac12()
{
    return mac12;
}

char *ReportInterface::returnMac18()
{
    return mac18;

}

bool ReportInterface::getReportState()
{
    return reportSuccess;
}

void ReportInterface::SetReportState(bool state)
{
    if (state)
    {
        saveConfig("UpTime", uploadTime);
    }
    reportSuccess = state;
}

sem_t* ReportInterface::getSem()
{
    return &sem_report;
}

bool ReportInterface::packGetDataMsg()
{
    time_t rawtime;
    time(&rawtime);
    rawtime -= 10;
    if (uploadTime >= static_cast<uint64_t>(rawtime))
        return false;
    LogInfo("pack get DataMsg");
    std::vector< WrapperCmdPara > getData;
    getData.push_back(WrapperCmdPara(PARA_TYPE_DATASTOR_NUM_RECORDS_PER_MESSAGE, static_cast<uint32_t>(50)));
    getData.push_back(WrapperCmdPara(PARA_TYPE_DATASTOR_BEGIN_TIME, static_cast<uint64_t>(uploadTime)));
    getData.push_back(WrapperCmdPara(PARA_TYPE_DATASTOR_END_TIME, static_cast<uint64_t>(rawtime)));
    MsgHandlerPtr->reponseToModule(MODULE_DATAM, MSG_TYPE_COMMAND, CMD_SET, CMD_CODE_PHONE_INFO_TRANSFER_START, getcmdIndex(), getData);
    return true;

}

bool ReportInterface::packUploadAck()
{
    LogInfo("pack upload ACK ");
    std::vector< WrapperCmdPara > uploadAck;
    MsgHandlerPtr->reponseToModule(MODULE_DATAM, MSG_TYPE_COMMAND, CMD_EVENT_RESPONSE, CMD_CODE_PHONE_INFO_DATA, getcmdIndex(), uploadAck);
    return true; 

}

bool ReportInterface::packStopUpload()
{ 
    LogInfo("pack Stop UpoOad");
    std::vector< WrapperCmdPara > uploadStop;
    MsgHandlerPtr->reponseToModule(MODULE_DATAM, MSG_TYPE_COMMAND, CMD_SET, CMD_CODE_PHONE_INFO_TRANSFER_STOP, getcmdIndex(), uploadStop);
    return true; 
}


bool ReportInterface::saveConfig(const char *name , const char *value)
{
    int32_t n;
    struct ndb_ctx_t ctx;
    struct ndb_tabset_t set;    
    struct ndb_ns_t* nslist[] = {&config_ns, &protocol_ns};
    ndb_create_context(&ndb, NULL, &ctx);
    ndb_register_namespaces(&ctx, nslist, 2);
    n = ndb_query(&ndb, &ctx, xpath, &set);
    if (n == -1)
    {
        LogError("no elenemt found in path %s ", xpath);
        return false;
    }
    
    int32_t i;
    ndb_elem_ptr rootp, elp;
    struct ndb_value_t ndb_value;
    ndb_elset_ptr elset = get_elem_set(&set);
    for_each_subtree(elset, rootp, i)
    {
        for_each_children(rootp, elp)
        {
            NDB_SET_STR(&ndb_value, const_cast<char *>(value));
            ndb_compare_and_set(elp, name, &ndb_value);
        }

    }
    ndb_save(&ndb);
    ndb_destory_context(&ctx);
    return true;
}



bool ReportInterface::saveConfig(const char *name , const uint32_t value)
{
    int32_t n;
    struct ndb_ctx_t ctx;
    struct ndb_tabset_t set;    
    struct ndb_ns_t* nslist[] = {&config_ns, &protocol_ns};
    ndb_create_context(&ndb, NULL, &ctx);
    ndb_register_namespaces(&ctx, nslist, 2);
    n = ndb_query(&ndb, &ctx, xpath, &set);
    if (n == -1)
    {
        LogError("no elenemt found in path %s ", xpath);
        return false;
    }
    
    int32_t i;
    ndb_elem_ptr rootp, elp;
    struct ndb_value_t ndb_value;
    ndb_elset_ptr elset = get_elem_set(&set);
    for_each_subtree(elset, rootp, i)
    {
        for_each_children(rootp, elp)
        {
            NDB_SET_U32(&ndb_value, value);
            ndb_compare_and_set(elp, name, &ndb_value);
        }

    }
    ndb_save(&ndb);
    ndb_destory_context(&ctx);
    LogDebug("save %s to %d success", name, value);
    return true;
}

bool ReportInterface::saveConfig(const char *name , const uint64_t value)
{
    int32_t n;
    struct ndb_ctx_t ctx;
    struct ndb_tabset_t set;    
    struct ndb_ns_t* nslist[] = {&config_ns, &protocol_ns};
    ndb_create_context(&ndb, NULL, &ctx);
    ndb_register_namespaces(&ctx, nslist, 2);
    n = ndb_query(&ndb, &ctx, xpath, &set);
    if (n == -1)
    {
        LogError("no elenemt found in path %s ", xpath);
        return false;
    }
    
    int32_t i;
    ndb_elem_ptr rootp, elp;
    struct ndb_value_t ndb_value;
    ndb_elset_ptr elset = get_elem_set(&set);
    for_each_subtree(elset, rootp, i)
    {
        for_each_children(rootp, elp)
        {
            NDB_SET_U32(&ndb_value,  value);
            ndb_compare_and_set(elp, name, &ndb_value);
        }

    }
    ndb_save(&ndb);
    ndb_destory_context(&ctx);
    LogDebug("save %s to %llu success", name, value);
    return true;
}

uint16_t ReportInterface::getcmdIndex()
{
    if (cmdIndex > 1024)
        cmdIndex = 0;
    return cmdIndex;

}
void ReportInterface::handleGetDataTmOut()
{
    LogInfo("time out get data time is %llu", uploadTime);
    if (reportSuccess)
    {
        packGetDataMsg();
    }
    TimerPtr->queue(ReportIntvl, &getDataTimeOut_);
}
void ReportInterface::setReportIntvl(int intvl)
{
    ReportIntvl = intvl;
}


bool ReportInterface::getcmdRsp(char *cmd, char *rspdata, int32_t *data_len)
{
    FILE *fpipe = (FILE *)popen(cmd, "r");
    if ( fpipe == NULL )
    {
        LogError("can not fopen cdm %s", cmd);
        return false;    
    }
    char data[128];
  
    while ( NULL != fgets(data, 128, fpipe) )
    {
        *data_len += strlen(data);
        if ( *data_len >= 1024 )
        {
            break;
        }
        strcat(rspdata, data);
        memset(data, 0, 128);
       
   }
   pclose(fpipe);
   LogDebug("cmd is %s , rspdata is %s", cmd, rspdata);
   return true;
}

ReportPhone::ReportPhone():
slotId(0),
uptime(0)
{
   memset(imsi, 0, 16);
   memset(imei, 0, 16);
   memset(tmsi, 0, 16);
}
#ifdef HTTP

HttpReport::HttpReport():
initialzed(false)
{

    memset(addr, 0, 128);
    memset(dataType, 0, 16);
    memset(place, 0, 16);
    memset(protocol, 0, 16);
    memset(md5Key, 0, 16);
}

HttpReport::~HttpReport()
{
}

bool HttpReport::initialze()
{
  //  strcpy(addr, "http://wf.marknum.cn:8052/manager/data/queryServers.html");
   // strcpy(dataType, "imei");
  //  strcpy(place, "41030029000001");
   // strcpy(protocol, "imei");
   // strcpy(md5Key, "%^&$#@");

    initialzed = true;
    time_t timenow;
    time(&timenow);
    //setTime(1490865174);
    memset(getndb(), 0, sizeof(ndb_t));
    if ( ndb_create(getndb(), PROTOCOL_CONFIG_FIEL) == 0 )
    {
        LogNotice("load %s file success", PROTOCOL_CONFIG_FIEL);
    }
    else if ( ndb_create(getndb(), PROTOCOL_CONFIG_FIEL_EXTERNAL) != 0)
    {
         
        LogEmergency("failed to load file %s and %s",  PROTOCOL_CONFIG_FIEL_EXTERNAL);
        return false;
    }
    int32_t n ;
    struct ndb_cursor_t cursor;
    struct ndb_ctx_t ctx;
    struct ndb_tabset_t set;
    struct ndb_ns_t* nslist[] = {&config_ns, &protocol_ns};
    ndb_create_context(getndb(), NULL, &ctx);
    ndb_register_namespaces(&ctx, nslist, 2);
    n = ndb_query(getndb(), &ctx, xpath, &set);
    if (n == -1)
    {
        LogError("no elenemt found in path %s ", xpath);
        return false;
    }
    memset(&cursor, 0, sizeof(struct ndb_cursor_t));
     
    for_each_table(&set, &cursor)
    { 
        ndbc_down(&cursor);
        do
        {
            if ( strcmp(ndbc_get_name(&cursor), "HttpUrl") == 0 )
            {   
                LogInfo("xml config httpUrl is %s", ndbc_get_value_as_str(&cursor));
                strcpy(addr, ndbc_get_value_as_str(&cursor));
                
            }
            else if ( strcmp(ndbc_get_name(&cursor), "DataType") == 0 )
            {
                strcpy(dataType, ndbc_get_value_as_str(&cursor));
                LogInfo("xml config DataType is %s", dataType);
            }
            else if ( strcmp(ndbc_get_name(&cursor), "PlaceNum") == 0)
            {
                strcpy(place, ndbc_get_value_as_str(&cursor));
                LogInfo("xml config PlaceNum is %s", place);

            }
            else if ( strcmp(ndbc_get_name(&cursor), "Protocol") == 0)
            {
                strcpy(protocol, ndbc_get_value_as_str(&cursor));
                LogInfo("xml config Protocol is %s", protocol);
            }
            else if ( strcmp(ndbc_get_name(&cursor), "MD5Key") == 0)
            {
                strcpy(md5Key, ndbc_get_value_as_str(&cursor));
                LogInfo("xml config MD5Key is %s", md5Key);
            }
            else if ( strcmp(ndbc_get_name(&cursor), "ReportIntvl") == 0)
            {
                setReportIntvl(ndbc_get_value_as_int32(&cursor));
                LogInfo("xml config ReportIntvl is %d", getReportIntvl());
            }
            else if ( strcmp(ndbc_get_name(&cursor), "UpTime") == 0)
            {
                setTime(ndbc_get_value_as_u32(&cursor));
                LogInfo("xml config UpTIme is %llu", getTime());
            }

        }while(ndbc_move(&cursor) == 0);

    }
    ndb_destory_context(&ctx);
    initReport();
    return true;
}

bool HttpReport::initialzedM()
{
    return initialzed;
}

bool HttpReport::CommitData()
{
    time_t uptime;
    time(&uptime);
    memset(filename, 0, 128);
    sprintf(filename,  "%s_%s-%12s-%s-%lu", dataType, protocol, returnMac12(), place, uptime);
    memset(recordPath, 0, 128);
    sprintf(recordPath, "%s/%s.log", recordDir, filename);
    FILE *fp = NULL;
    fp = fopen(recordPath, "a");
    if (fp == NULL)
    {
        LogError("can not open record : %s", recordPath);
        phoneList_.clear();
        return false;
    }
    for (std::list<ReportPhone> ::iterator it=phoneList_.begin(); it!=phoneList_.end(); it++)
    {
        fprintf(fp, "%s\t%s\t%llu\t%d\t%s\t%s\t%s\r\n", returnMac18(), "00:00:00:00:00:00", it->uptime, it->slotId, it->imei, it->imsi, it->tmsi);
    }    
    setTime( phoneList_.back().uptime + 1);
    fflush(fp);
    fclose(fp);

    phoneList_.clear();
    while ((dup2(STDOUT_FILENO, STDERR_FILENO)==-1) && (errno==EINTR))
    {
    };
    SetReportState(false);
    sem_post(getSem());
    return true;

}

bool HttpReport::saveData(uint8_t *paraValue)
{
    ReportPhone phone;
    phone.uptime =  *((uint64_t*)paraValue);
    phone.slotId= *((int32_t *)paraValue + 2);
    uint8_t *tmpvalue = paraValue + sizeof(uint64_t) + sizeof(uint32_t);
    strcpy((char *)phone.imsi, (char* )tmpvalue);
    tmpvalue += strlen((char *)tmpvalue) + 1;
    strcpy((char *)phone.imei, (char* )tmpvalue);
    tmpvalue += strlen((char *)tmpvalue) + 1;    
    strcpy((char *)phone.tmsi, (char* )tmpvalue);
    tmpvalue += strlen((char *)tmpvalue) + 1;  
    phoneList_.push_back(phone);
    LogDebug("IMSI: %s  IMEI: %s  slotId: %d time: %llu", phone.imsi, phone.imei, phone.slotId, phone.uptime); 
    return true;
}

bool HttpReport::ReportPrepare()
{
   return false;

}

bool HttpReport::DataReport()
{
    LogWarning("report msg false");
    LogInfo("%s", addr);
    return false;
}

bool HttpReport::ReportSuccess()
{
    return false;
}
uint32_t HttpReport::recordSize()
{
    return phoneList_.size();
}

#endif

#ifdef FTP
FtpReport::FtpReport():
initialzed(false)
{
    memset(addr, 0, 128);
    memset(usr, 0, 128);
    memset(password, 0, 128);
    memset(company, 0, 128);
    memset(BSIC, 0, 16);
    memset(filename, 0, 128);
}

FtpReport::~FtpReport()
{
}

bool FtpReport::initialze()
{

    initialzed = true;
    memset(getndb(), 0, sizeof(ndb_t));
    if ( ndb_create(getndb(), PROTOCOL_CONFIG_FIEL) == 0 )
    {
        LogNotice("load %s file success", PROTOCOL_CONFIG_FIEL);
    }
    else if ( ndb_create(getndb(), PROTOCOL_CONFIG_FIEL_EXTERNAL) != 0)
    {
         
        LogEmergency("failed to load file %s and %s",  PROTOCOL_CONFIG_FIEL_EXTERNAL);
        return false;
    }
    int32_t n ;
    struct ndb_cursor_t cursor;
    struct ndb_ctx_t ctx;
    struct ndb_tabset_t set;
    struct ndb_ns_t* nslist[] = {&config_ns, &protocol_ns};
    ndb_create_context(getndb(), NULL, &ctx);
    ndb_register_namespaces(&ctx, nslist, 2);
    n = ndb_query(getndb(), &ctx, xpath, &set);
    if (n == -1)
    {
        LogError("no elenemt found in path %s ", xpath);
        return false;
    }
    memset(&cursor, 0, sizeof(struct ndb_cursor_t));
     
    for_each_table(&set, &cursor)
    { 
        ndbc_down(&cursor);
        do
        {
            if ( strcmp(ndbc_get_name(&cursor), "FtpAddr") == 0 )
            {   
              
                strcpy(addr, ndbc_get_value_as_str(&cursor));
                LogInfo("xml config FtpAddr is %s", addr);
                
            }
            else if ( strcmp(ndbc_get_name(&cursor), "User") == 0 )
            {
                strcpy(usr, ndbc_get_value_as_str(&cursor));
                LogInfo("xml config User is %s", usr);
            }
            else if ( strcmp(ndbc_get_name(&cursor), "Password") == 0)
            {
                strcpy(password, ndbc_get_value_as_str(&cursor));
                LogInfo("xml config Password is %s", password);

            }
            else if ( strcmp(ndbc_get_name(&cursor), "Port") == 0)
            {
                port = ndbc_get_value_as_int32(&cursor);
                LogInfo("xml config port is %d", port);
            }
            else if ( strcmp(ndbc_get_name(&cursor), "Company") == 0)
            {
                strcpy(company, ndbc_get_value_as_str(&cursor));
                LogInfo("xml config Company is %s", company);
            }
            else if ( strcmp(ndbc_get_name(&cursor), "BSIC") == 0)
            {
                strcpy(BSIC, ndbc_get_value_as_str(&cursor));
                LogInfo("xml config BSIC is %s", BSIC);
            }
            else if ( strcmp(ndbc_get_name(&cursor), "ReportIntvl") == 0)
            {
                setReportIntvl(ndbc_get_value_as_int32(&cursor));
                LogInfo("xml config ReportIntvl is %d", getReportIntvl());
            }
            else if ( strcmp(ndbc_get_name(&cursor), "UpTime") == 0)
            {
                setTime(ndbc_get_value_as_u32(&cursor));
                LogInfo("xml config UpTIme is %llu", getTime());
            }

        }while(ndbc_move(&cursor) == 0);

    }
    ndb_destory_context(&ctx);
    initReport();
    return true;


}

bool FtpReport::CommitData()
{
    time_t uptime;
    time(&uptime);
    char szbuf[64] = {0};
    strftime(szbuf, 64, "%Y%m%d%H%M%S", localtime(&uptime));
    memset(filename, 0, 128);
    //sprintf(filename,  "%s_%s_%s", company, BSIC, szbuf);
    sprintf(filename, "Hotpoint_0_%s_0_%s", BSIC, szbuf);
    memset(recordPath, 0, 128);
 //   sprintf(recordPath, "%s/%s.txt", recordDir, filename);
    sprintf(recordPath, "%s/%s.hp", recordDir, filename);
    FILE *fp = NULL;
    fp = fopen(recordPath, "a");
    if (fp == NULL)
    {
        LogError("can not open record : %s", recordPath);
        phoneList_.clear();
        return false;
    }
    for (std::list<ReportPhone> ::iterator it=phoneList_.begin(); it!=phoneList_.end(); it++)
    {
        /*
        memset(szbuf, 0, 64);
        
        strftime(szbuf, 64, "%Y-%m-%d %H:%M:%S", localtime(((time_t *)(&it->uptime))));
        if (strlen(it->imei) == 0)
        {
            fprintf(fp, "%s\t%s\t%s\r\n", it->imsi, "000000000000000", szbuf);
        }
        else
        {
            fprintf(fp, "%s\t%s\t%s\r\n", it->imsi, it->imei, szbuf);
        }*/

        switch(it->slotId)
        {
            case 1:
                   fprintf(fp, "%s40\t%s\t%s\t\t%llu\t1\r\n", BSIC, it->imsi, it->imei, it->uptime);
                   break;
            case 2:
                   fprintf(fp, "%s42\t%s\t%s\t\t%llu\t1\r\n", BSIC, it->imsi, it->imei, it->uptime);
                   break;
            case 3:
                   fprintf(fp, "%s41\t%s\t%s\t\t%llu\t1\r\n", BSIC, it->imsi, it->imei, it->uptime);
                   break;
            case 4:
            case 5:
                   fprintf(fp, "%s40\t%s\t%s\t\t%llu\t1\r\n", BSIC, it->imsi, it->imei, it->uptime);
                   break;
            case 6:
                   fprintf(fp, "%s47\t%s\t%s\t\t%llu\t1\r\n", BSIC, it->imsi, it->imei, it->uptime);
                   break; 
            case 7:
                   fprintf(fp, "%s44\t%s\t%s\t\t%llu\t1\r\n", BSIC, it->imsi, it->imei, it->uptime);
            default:
                   break;
        }
    }    
    setTime( phoneList_.back().uptime + 1);
    fflush(fp);
    fclose(fp);

    phoneList_.clear();
    while ((dup2(STDOUT_FILENO, STDERR_FILENO)==-1) && (errno==EINTR))
    {
    };
    SetReportState(false);
    sem_post(getSem());
    return true;
}

bool FtpReport::ReportPrepare()
{
    char cmd[128] = {0};
    char rspdata[1024] = {0};
    int32_t len = 0;
    sprintf(cmd, "ping -c 1 %s", addr);
    getcmdRsp(cmd, rspdata, &len);
    if ( strstr(rspdata, "time="))
    {
        int32_t ptime = atoi(strstr(rspdata, "time=")+5);
        if ( ptime > 10000 )
        {
            return false;
        }
        return true;
    }
    return false;
}


bool FtpReport::saveData(uint8_t *paraValue)
{
    ReportPhone phone;
    phone.uptime =  *((uint64_t*)paraValue);
    phone.slotId= *((int32_t *)paraValue + 2);
    uint8_t *tmpvalue = paraValue + sizeof(uint64_t) + sizeof(uint32_t);
    strcpy((char *)phone.imsi, (char* )tmpvalue);
    tmpvalue += strlen((char *)tmpvalue) + 1;
    strcpy((char *)phone.imei, (char* )tmpvalue);
    tmpvalue += strlen((char *)tmpvalue) + 1;    
    strcpy((char *)phone.tmsi, (char* )tmpvalue);
    tmpvalue += strlen((char *)tmpvalue) + 1;  
    phoneList_.push_back(phone);
    LogDebug("IMSI: %s  IMEI: %s  slotId: %d time: %llu", phone.imsi, phone.imei, phone.slotId, phone.uptime); 
    return true;
}

bool FtpReport::DataReport()
{
    char cmd[256] = {0};
    sprintf(cmd, "curl -u %s:%s -T %s ftp://%s:%d ", usr, password, recordPath, addr, port);
    pid_t status;
    status = system(cmd);
    LogInfo("system cmd is %s status is %d", cmd, WEXITSTATUS(status));
    if ( status == -1 )
    {
        LogError("system error cmd is %s", cmd);
    }
    else
    {
        if ( WIFEXITED(status) )
        {
            LogDebug("cmd exit normal ")
            if ( WEXITSTATUS(status) == 0)
            {
                LogDebug("upload data success file is  %s", recordPath);
                return true;
            }   
        }
        else
        {

            LogError("cmd exit abnormal");
        }

    }
    
    return false;
}

bool FtpReport::ReportSuccess()
{
   return true;
}

bool FtpReport::initialzedM()
{
    return initialzed;
}

uint32_t FtpReport::recordSize()
{
    return phoneList_.size();

}


#endif
